import { PageDateSelect } from '@/types/pages/enum';
import { IFinance } from '@/types/pages/finance/interface';
import Mock from 'mockjs'
import { IDateLineChart, IDatePieChart } from '@/types/echart';
import { TransportCarriage, TransportCarriageList, TransportCosts, TransportCostsList } from '@/types/pages/transportCosts/interface';

export const getTransportCarriageData: (type: PageDateSelect, date?: Date) => Promise<TransportCarriageList> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        let data =  {
            carriage: { name: '承运商', unit: '', num: Mock.mock('@integer(10000, 50000)') },
            train: { name: '承运车', unit: '', num: Mock.mock('@integer(10000, 50000)') },
            car: { name: '铁路线', unit: '', num: Mock.mock('@integer(10000, 50000)') },
        }

        res(Mock.mock(data));
    })

}
export const getTransportCostsData: (type: PageDateSelect, date?: Date) => Promise<TransportCostsList> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        let data =  {
            carriage: { name: '承运商', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
            train: { name: '承运车', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
            car:{ name: '铁路线', totalNum: Mock.mock('@integer(10000, 50000)'), unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
        }
        res(Mock.mock(data));
    })

}

export const getCategoryPieChart: (type: PageDateSelect, date?: Date) => Promise<IDatePieChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset: IDatePieChart = { title: '运输品类', dataset: { dimensions: ['名称', '类型'], 'source': [{ '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '产品' + Mock.Random.cname(), '类型|1-100': 100, }, { '名称': '聚酯级' + Mock.Random.cname(), '类型|1-100': 100, }] } }
        res(Mock.mock(dataset));
    })
}
export const getAccountsT10ColumnChart: (type: PageDateSelect, date?: Date) => Promise<IDateLineChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a=()=>(Math.random()*100).toFixed(2)
        const dataset: IDateLineChart = { title: '承运商结算金TOP10',dataset:{dimensions:['客户','数值'],source:[{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()}]}}
        res(Mock.mock(dataset));
    })
}

export const getProfitT10ColumnChart: (type: PageDateSelect, date?: Date) => Promise<IDateLineChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a=()=>(Math.random()*100).toFixed(2)
        const dataset: IDateLineChart = { title: '承运费结单价TOP10',dataset:{dimensions:['客户','数值'],source:[{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()},{'客户':Mock.Random.cname(),'数值':a()}]}}
        res(Mock.mock(dataset));
    })
}


export const getTendencyLineChart: (ype: PageDateSelect, date?: Date) => Promise<IDateLineChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const a = () => (Math.random() * 100).toFixed(2)
        const dataset: IDateLineChart = { title: '利润趋势（万元）', dataset: { dimensions: ['date', '实际', '预测'], source: [{ 'date': '2021-01-7', '实际': a(), '预测': a() },{ 'date': '2021-01-8', '实际': a(), '预测': a() } , { 'date': '2021-01-9', '实际': a(), '预测': a() },{ 'date': '2021-01-10', '实际': a(), '预测': a() }] } }
        res(Mock.mock(dataset));
    })
}



